Don't blow away target/doc
authorAlex Crichton <alex@alexcrichton.com>
Tue, 29 Jul 2014 03:09:07 +0000 (20:09 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 29 Jul 2014 04:13:08 +0000 (21:13 -0700)
The existing rustdoc behavior for working with an already-present directory is
good enough, so there's no need for cargo to help out by blowing things away.
This also makes the copy-back portion easier by just not having it.

Closes #284

src/cargo/ops/cargo_doc.rs
tests/test_cargo_doc.rs

index f59bf9b04cd7b1998ce9bd57a4bc21bfc01f80b6..6252b2831d0ff74866da9e3357f76be5ed55f30c 100644 (file)
@@ -1,9 +1,5 @@
-use std::io::fs;
-
 use ops;
 use util::CargoResult;
-use core::source::Source;
-use sources::PathSource;
 
 pub struct DocOptions<'a> {
     pub all: bool,
@@ -12,11 +8,6 @@ pub struct DocOptions<'a> {
 
 pub fn doc(manifest_path: &Path,
            options: &mut DocOptions) -> CargoResult<()> {
-    let mut src = PathSource::for_path(&manifest_path.dir_path());
-    try!(src.update());
-    let root = try!(src.get_root_package());
-    let output = root.get_manifest().get_target_dir().join("doc");
-    let _ = fs::rmdir_recursive(&output);
     try!(ops::compile(manifest_path, &mut options.compile_opts));
     Ok(())
 }
index 6ca18abc4186c1f36b46d93c5a3527448fb03260..c6fc2856e12b2f41e3dcd78a2eb398a093ce27ac 100644 (file)
@@ -1,5 +1,5 @@
-use support::{project, execs};
-use support::{COMPILING};
+use support::{project, execs, cargo_dir};
+use support::{COMPILING, FRESH};
 use hamcrest::{assert_that, existing_file, existing_dir, is_not};
 
 fn setup() {
@@ -85,11 +85,11 @@ test!(doc_twice {
         compiling = COMPILING,
         dir = p.root().display()).as_slice()));
 
-    assert_that(p.cargo_process("cargo-doc"),
+    assert_that(p.process(cargo_dir().join("cargo-doc")),
                 execs().with_status(0).with_stdout(format!("\
-{compiling} foo v0.0.1 (file:{dir})
+{fresh} foo v0.0.1 (file:{dir})
 ",
-        compiling = COMPILING,
+        fresh = FRESH,
         dir = p.root().display()).as_slice()));
 })
 
@@ -129,6 +129,18 @@ test!(doc_deps {
     assert_that(&p.root().join("target/doc"), existing_dir());
     assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
     assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
+
+    assert_that(p.process(cargo_dir().join("cargo-doc")),
+                execs().with_status(0).with_stdout(format!("\
+{fresh} bar v0.0.1 (file:{dir})
+{fresh} foo v0.0.1 (file:{dir})
+",
+        fresh = FRESH,
+        dir = p.root().display()).as_slice()));
+
+    assert_that(&p.root().join("target/doc"), existing_dir());
+    assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
+    assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
 })
 
 test!(doc_no_deps {